<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>爱宠医院管理系统</title>
	<meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
	<meta http-equiv="expires" content="0"/>    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
	<meta http-equiv="description" content="This is my page"/>
	<link href="css/Common.css" rel="stylesheet" type="text/css" />
    <link href="css/sitegeneric08.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
  </head>
  
  <body>
<!-- head如果图片高度不合适。请修改Common.ces里面的".Header .HeaderTop"的高度。和".Header"的高度-->
<jsp:include flush="true" page="incTop.jsp"></jsp:include>    
<!-- head-->
	
	
	
	
<!--body-->
<div align="center" class="Wrapper">
<div id="MainCenter" align="center" class="MainCenter">
	     <div id="navigation" class="naivgation">
				<jsp:include flush="true" page="incLeft.jsp"></jsp:include>
		 </div>
		 <div id="content" class="Sub">
				<div class="NewContainer771">
					<div class="BoxHeader">
						<div class="BoxHeader-center MarginTop10">用户信息</div>
					</div>
					<div class="Slot"  style="height: 100%">
						<table width="80%" border="0">
						    <tbody>
							    <tr>
							       <td align="center">用户名：</td>
							       <td align="center"><span id='username_info'></span><hr/></td>
							    </tr>
							    <tr>
							       <td align="center">性别：</td>
							       <td align="center"><span id='sex_info'></span><hr/></td>
							    </tr>
							    <tr>
							       <td align="center">联系电话：</td>
							       <td align="center"><span id='phone_info'></span><hr/></td>
							    </tr>
							    <tr>
							       <td align="center">邮箱：</td>
							       <td align="center"><span id='email_info'></span><hr/></td>
							    </tr>
							</tbody>
						</table>
                    </div>
				</div>
				
		 </div>
		 
		<div id="content" class="Sub">
				<div class="NewContainer771">
					<div class="BoxHeader">
						<div class="BoxHeader-center MarginTop10">修改密码</div>
					</div>
					<div class="Slot"  style="height: 100%">
						<table width="80%" border="0">
						    <tbody>
						    <tr>
						       <td align="center">原始密码：</td>
						       <td align="center"><input type="text" class="form-control" id='oripass3' /></td>
						    </tr>
						    <tr>
						       <td align="center">新密码：</td>
						       <td align="center" ><input type="text" class="form-control" id='newpass3' placeholder="输入6-20个字母、数字、下划线" /></td>
						    </tr>
						  
						    <tr>
						       <td align="center" >重复密码：</td>
						       <td align="center" ><input type="text" class="form-control" id='newpass4' placeholder="输入6-20个字母、数字、下划线" /></td>
						    </tr>
						    <tr>
						       <td align="center" ></td>
						       <td align="center" ><input type="button" id='modify-pass' value="确定" /></td>
						    </tr>
						</tbody>
						</table>
                    </div>
				</div>
		 </div>
		 
		 
		    	<div id="content" class="Sub">
				<div class="NewContainer771">
					<div class="BoxHeader">
						<div class="BoxHeader-center MarginTop10">我的治疗记录</div>
					</div>
					<div>
                     <table class="table">
			              <thead>
				              <tr>
				             <th>编号</th>
						     <th>宠物名</th>
						     <th>主人名</th>
						     <th>宠物编号</th>
						     <th>宠物年龄</th>
						     <th>病因</th>
						     <th>主人电话</th>
						     <th>处理</th>
						     <th>医嘱</th>
			                  </tr>
			              </thead>
			              <tbody id="Repair">
			              </tbody>
	        		 </table>
                    </div>
				</div>
		 </div>
		    	<div id="content" class="Sub">
				<div class="NewContainer771">
					<div class="BoxHeader">
						<div class="BoxHeader-center MarginTop10">我的美容记录</div>
					</div>
					<div>
                     <table class="table">
			              <thead>
				              <tr>
				             <th>编号</th>
						     <th>美容项目</th>
						     <th>宠物名</th>
						     <th>美容时间</th>
			                  </tr>
			              </thead>
			              <tbody id="Complaints">
			              </tbody>
	        		 </table>
                    </div>
				</div>
		 </div>
		 
		 
</div>
</div>
<!--body-->
	
	
<!--foot -->	
<div align="center" class="Wrapper">
	<div style="height: 40px;" align="center" class="Footer">
		<ul style="margin-top: 13px;">
			<li>
				<a>网站声明</a>&nbsp;&nbsp; |&nbsp;&nbsp;
				<a>服务网点</a>&nbsp;&nbsp; |&nbsp;
				<a>网站地图</a>&nbsp; |&nbsp;&nbsp;
				<a>联系我们</a>&nbsp;&nbsp; |&nbsp;&nbsp;
				<a>客服热线：********</a> 
			</li>
		</ul>
	</div>
</div>
<!--foot -->
<script type="text/javascript">

var userid = getCookie('userid');
$(function(){
	if(isEmpty(userid)){
		alert('请先登录');
		window.location.href = 'index.jsp'
		return false;
	}
	
	//获取user用户的信息
	$.get("../api/user/getbyid",{id:userid},function(data){
		//console.log(data);
		var obj = data.data;
		    $('#username_info').text(obj.username);
		    $('#sex_info').text(obj.sex);
		    $('#phone_info').text(obj.phone);
		    $('#email_info').text(obj.email);
	});
});

function isPasswd(s){    
	var patrn=/^(\w){6,20}$/;    
	if (!patrn.exec(s)) return false  
	return true  
} 

//修改密码
$('#modify-pass').click(function(){
	var oripass3 = $('#oripass3').val();
	var newpass3 = $('#newpass3').val();
	var newpass4 = $('#newpass4').val();
	if (!isPasswd(newpass3)) {
		alert('密码格式不正确');
		return false;
	}
	
	if (newpass3 != newpass4) {
		alert('两次密码不一样');
		return false;
	}
	
	var obj = {};
	obj.userid = userid;
	obj.oripass = oripass3;
	obj.newpass = newpass3;
	$.post('../api/user/modifypass',obj,function(data){
		if (data.code == '0') {
			alert('修改成功');
			window.location.reload();
		}
	});

});



//查找我的治疗记录
var obj = {};
obj.userid = userid;
obj.page = 1;
obj.number = 10;
$.get('../api/repair/list',obj,function(data){
	if (data.code == '0') {
		var arr = data.data;
		var html = '';
		for (var i=0,len=arr.length;i<len;i++) {
			var oj = arr[i];
			var clas = 'success';
			if (i%2==1) { clas = 'danger'; }
			var state = oj.state;
			if(state=='0' || isEmpty(state)){
				state = '未处理';
			}else{
				state = '已处理';
			}
			
			html += '<tr class="'+clas+'" onclick="javascript:window.location.href=\'repair_detail.jsp?'+$.param(oj)+'\'">' 
			       	+'<td>'+(i+1)+'</td>'
					+'<td>'+oj.title+'</td>'
					+'<td>'+oj.building+'</td>'
					+'<td>'+oj.houseNum+'</td>'
					+'<td>'+oj.name+'</td>'
					+'<td>'+oj.detail+'</td>'
					+'<td>'+oj.phone+'</td>'
				     +'<td>'+state+'</td>'
					+'<td>'+(isEmpty(oj.evaluation)?"":oj.evaluation)+'</td>'
		            +'</tr>';
		}
		document.getElementById('Repair').innerHTML = html;
	}
})
    
//查找我的美容记录
var obj = {};
obj.userid = userid;
obj.page = 1;
obj.number = 10;
$.get('../api/complaints/list',obj,function(data){
	if (data.code == '0') {
		var arr = data.data;
		var html = '';
		for (var i=0,len=arr.length;i<len;i++) {
			var oj = arr[i];
			var clas = 'success';
			if (i%2==1) { clas = 'danger'; }
			html += '<tr class="'+clas+'" onclick="javascript:window.location.href=\'complaints_detail.jsp?'+$.param(oj)+'\'">' 
			       	+'<td>'+(i+1)+'</td>'
					+'<td>'+oj.name+'</td>'
					+'<td>'+oj.reason+'</td>'
					+'<td>'+oj.cpTime+'</td>'
		            +'</tr>';
		}
		document.getElementById('Complaints').innerHTML = html;
	}
})
    


</script>		
</body>
</html>
